Skip to content

Fix pr-status to work without --pr parameter#2521

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-status-optional-parameter
Draft

Fix pr-status to work without --pr parameter#2521
Copilot wants to merge 2 commits intomainfrom
copilot/fix-pr-status-optional-parameter

Conversation

Copy link

Copilot AI commented Feb 10, 2026

The pr-status command fails when --pr is omitted because getPrNumber() calls process.exit(1) on missing PR, which bypasses the try-catch meant to handle this case. This breaks merge queue workflows where only --sha is available.

Changes

  • packages/core/src/auto.ts: Changed prStatus() to call getPrNumberFromEnv() directly instead of getPrNumber(). This returns undefined when no PR is found, allowing the existing fallback logic to use the provided SHA or HEAD.
  • packages/core/src/tests/auto.test.ts: Removed assertion for process.exit call in test that was validating the buggy behavior.

Example

This now works in merge queue events:

auto pr-status \
  --sha ${{ github.sha }} \
  --context "Auto PR Check" \
  --state success \
  --description "PR labels validated"
Original prompt

This section details on the original issue you should resolve

<issue_title>pr-status doesn't work when we don't pass the optional --pr parameter</issue_title>
<issue_description>Describe the bug

the pr-status command has an optional parameter --pr. This command was design to only use the PR number when we don't pass a --sha parameter. Even if we don't pass the --sha and --pr parameters, the command was designed to obtain the sha from the HEAD of the current branch.

The code has a try-catch to prevent auto from throwing an error when the PR number is not available. But this try-catch is not working because the getPrNumber() function calls process.exit(1). The try-catch is not able to stop that.

process.exit(1);

try {
prNumber = this.getPrNumber("pr", pr);
} catch (error) {
// default to sha if no PR found
}

To Reproduce

Try to create a commit status during the merge_group event (merge queue) (or even the push event). This might be needed when Auto PR Check is a required status check that is set by auto pr-check in the pull_request event. Since it's a required status check, for repos using the merge queue, it also needs to be set during merge_group event (merge queue). In this case, there's no PR number. It should be enough using --sha ${{ github.sha }}.

auto pr-status --url ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} --context "Auto PR Check" --sha ${{ github.sha }} --state success --description "PR labels validated in original PR"

Expected behavior

pr-status should work even if we don't pass the --pr parameter.

Screenshots

Environment information:

ℹ  info      ENV: {
  isCi: true,
  name: 'GitHub Actions',
  service: 'github',
  commit: 'dfd<redacted>f9d',
  build: '1<redacted>2',
  isPr: false,
  branch: 'gh-readonly-queue/main/pr-123-efb<redacted>de6',
  prBranch: undefined,
  slug: '<redacted>/<redacted>',
  root: '/home/<redacted>'
}

Additional context

N/A
</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: adierkens <13004162+adierkens@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix pr-status command when missing optional parameters Fix pr-status to work without --pr parameter Feb 10, 2026
Copilot AI requested a review from adierkens February 10, 2026 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr-status doesn't work when we don't pass the optional --pr parameter

2 participants